home *** CD-ROM | disk | FTP | other *** search
/ Windows Expert / Windows Expert.iso / utility / pubtech.zip / BWSCRIPT.PTB < prev    next >
Text File  |  1990-05-22  |  10KB  |  370 lines

  1. ;  PubTech BatchWorks Demo
  2. debug(@off)
  3. DaTitle="PubTech BatchWorks Demo" 
  4. crlf = strcat(num2char(13),num2char(10))
  5.  
  6. ; Set the length of time to be used for DISPLAY statements
  7. TimeShort=3
  8. TimeLong=6
  9.  
  10. ;  close any extraneous windows, except Command Post and/or MS-DOS
  11. ;  Note that PubTech Batch should not close itself
  12. wincloseall("Desktop","CBM Desktop","PubTech File","File","MS-","Program")
  13. ;  get Windows shells iconized.  Also test error supression.
  14. error(@off)
  15. winiconize("MS-")
  16. winiconize("Program")
  17. winiconize("File Manager")
  18. ;  return to error cancel state
  19. error(@cancel)
  20.  
  21. :START
  22.  
  23. savecwd=dirget()
  24. a="Betty Boop"
  25.  
  26. beep
  27.  
  28. ;  Display start message
  29. display(3,DaTitle,`This is the PubTech BatchWorks Demo`)
  30. display(%TimeLong%,DaTitle,`A BatchWorks script was written to create this demonstration`)
  31. display(%TimeLong%,DaTitle,`It's easy for a user to automate virtually all Windows functions`)
  32. display(%TimeLong%,DaTitle,`For instance, we can start the clock using the BatchWorks RUN command...`)
  33.  
  34. run("clock.exe","")
  35.  
  36. display(%TimeLong%,DaTitle,`The clock is on screen now`)
  37. display(%TimeLong%,DaTitle,`Now we will close the clock`)
  38.  
  39. winclose("Clock")
  40.  
  41. display (2,DaTitle,"The clock window just closed")
  42.  
  43. display(%TimeLong%,DaTitle,`Now we will open the cardfile ZOOMED`)
  44.  
  45. runzoom("cardfile.exe","")
  46. display(%TimeLong%,DaTitle,`OK so far?`)
  47. display(%TimeLong%,DaTitle,`Let's close the cardfile and do a few more things`)
  48.  
  49. winclose("Cardfile")
  50.  
  51. display(%TimeLong%,DaTitle,`We can run the notepad and hide it with the RUNHIDE command`)
  52.  
  53. runhide("notepad.exe","")
  54.  
  55. display(%TimeLong%, DaTitle,"Notepad is running, but it's hidden; Let's use the WINSHOW command to show it")
  56. WINSHOW("Notepad")
  57. display(%TimeLong%, DaTitle,"Notepad is showing now")
  58.  
  59. display(%TimeLong%,DaTitle,`Now let's iconize it with the WINICONIZE command`)
  60. WinIconize("Notepad")
  61.  
  62.  
  63. display(%TimeLong%,DaTitle,`Let's run a couple more apps`)
  64. run("Cardfile.exe",'')
  65. run("calendar.exe","")
  66. display(%TimeLong%,DaTitle,`Now we want to activate notepad too`)
  67. winactivate("Notepad")
  68.  
  69. display(%TimeLong%,DaTitle,`Now we can arrange everything with the WINARRANGE command`)
  70. WinArrange("Stackemup oinkser")
  71.  
  72. display(%TimeLong%,DaTitle,`Let's close everything but the Notepad and Windows shell`)
  73. WinCloseall( "Notepad","Desktop","CBM Desktop","PubTech File","File","MS-","Program" )
  74. ;  get Windows shells iconized
  75. error(@off)
  76. winiconize("MS-")
  77. winiconize("File Manager")
  78. winiconize("Program")
  79. ;  return to error cancel state
  80. error(@cancel)
  81. display(%TimeLong%, DaTitle,"Now only the Notepad is active")
  82. WinCloseall("Desktop","CBM Desktop","PubTech File","File","MS-","Program")
  83. display(%TimeLong%, DaTitle,"Now everything has been closed")
  84.  
  85.  
  86. ;    well.  Lets try zooping the old clock around
  87. ;    with the place statement
  88.  
  89. display(%TimeLong%, DaTitle,"Now for some fancy footwork")
  90. display(%TimeLong%,DaTitle,`We can use the WINPLACE command to size and place windows`)
  91.  
  92. run("clock.exe","")
  93. z = 11
  94. a = 0
  95. b = 0
  96.  
  97. :clk1
  98. if z == 0 then goto clk2
  99. z = z - 1
  100. c = a + 300
  101. d = b + 200
  102. WinPlace(a,b,c,d,"Clock")
  103. a = a + 70
  104. b = b + 80
  105. goto clk1
  106.  
  107. :clk2
  108.  z = 11
  109.  a = 700
  110.  b = 0
  111.  
  112. :clk3
  113.  
  114. if z == 0 then goto clk4
  115. z = z - 1
  116. c = a + 300
  117. d = %b% + 200   ; stuff in a substitute here to be sure it still works
  118. WinPlace(a,b,c,d,'Clock')
  119. a = a - 70
  120. b = b + 80
  121. goto clk3
  122.  
  123.  
  124. :clk4
  125. WinClose("Clock")
  126.  
  127. display(%TimeLong%,DaTitle,`BatchWorks gives you the power to do just about anything Windows can do`)
  128.  
  129. display(%TimeLong%,DaTitle,"Here is an example of some file management")
  130. display(%TimeLong%,DaTitle,"Your config.sys file will be displayed")
  131.  
  132. dexist=FILEEXIST("c:\config.sys")
  133. if dexist == 0 then goto sorry
  134.  
  135. logdisk("c")
  136. error(@off)
  137. DirMake("\ptdemo")
  138. error(@cancel)
  139.  
  140. FileCopy("\config.sys","\ptdemo\dummy.txt")
  141. DirChange("\ptdemo")
  142. FileMove("dummy.txt","muddy.txt")
  143.  
  144. textbox("Config.Sys","muddy.txt")
  145.  
  146. FileDelete("muddy.txt")
  147. DirChange("\")
  148. DirRemove("\ptdemo")
  149.  
  150. goto notsorry
  151.  
  152. :sorry
  153.  
  154. display(%TimeLong%,DaTitle,"Oops! You don't have a config.sys file!")
  155.  
  156. :notsorry
  157.  
  158.  
  159. display(%TimeLong%,DaTitle,`You can open files, delete files, copy files, create directories`)
  160. display(%TimeLong%,DaTitle,`Your imagination is the limit`)
  161.                     
  162. display(%TimeLong%,DaTitle,`Let's do a little user interaction`)
  163.  
  164. :rename
  165. a=askline("Your Name Please","Please enter your full name","")
  166. a=strtrim(a)
  167.  
  168. b=strlen(a)
  169. if b != 0 then goto nameok
  170. display(3,DaTitle,"Look, You gotta enter something to get past here")
  171. goto rename
  172.  
  173.  
  174. :nameok
  175.  
  176. execute display(3,DaTitle,"Thank you, %a%")
  177.  
  178. display(%TimeLong%,DaTitle,`Now let's do some fancy calculations`)
  179. display(3,"%a%","Your name is %b% characters long")
  180.  
  181. ;  string mashing test
  182. exclusive(@on)
  183. ;  Parse name into component parts
  184. ;  %a full name
  185. ;  %b name length
  186. ;  %c pointer
  187. ;  %d current character
  188. ;  %f reserved for saving original dir
  189. ;  %h name count (first=1, middle=2 last=3 etc)
  190. ;  %i indirect character for name
  191. ;  %j variables for name
  192. ;  %l space flag
  193. ;  %m First name
  194. ;  %n middle name (if entered)
  195. ;  %o last name
  196. ;     etc
  197.  
  198.   c = 0
  199.   h = 1
  200.   i = "M"
  201.   j = "MNOPQRSTUVWXYZ"
  202.   l = 0
  203.   M = ''
  204. :loop
  205. if c == b then goto report
  206. c = c + 1
  207. ;  get first char
  208. d=strsub(a,c,1)
  209. if d== ' ' then goto space
  210. ;  not a space
  211. l = 0
  212.  
  213. %i%=strcat(%i%,d)
  214. goto loop
  215.  
  216. :space
  217. if l == 1 then goto loop
  218. l = 1
  219. h = h + 1
  220. i=strsub(j,h,1)
  221. %i% = ''
  222. goto loop
  223.  
  224. :report
  225. if h > 8 then h = 8
  226. y = "PARSE"
  227. ; compare computed results with the parse function
  228. parsedata(a)
  229. if param0 <> h then goto failure
  230. Display(3,a,"Your name has %h% parts. They are:")
  231. w = 0
  232. :report2
  233. if h == w then goto envtest
  234. w = w + 1
  235. i=strsub(j,w,1)
  236. display(3,"Name %w%",%i%)
  237. if param%w% != %i% then goto failure
  238. goto report2
  239.  
  240. :envtest
  241.  
  242. display(%TimeLong%,DaTitle,`Now let's get some environment information`)
  243. exclusive(@off)
  244. ;  getenv test
  245. path=environ("path")
  246. pathlen=strlen(path)
  247. pathwork=""
  248. i=1
  249.  
  250. :Looppath
  251. if pathlen-i < 65 then goto OKPATH
  252. j=i+64
  253. j=strindex(path,';',j,@backscan)
  254. pathwork=strcat(pathwork,strsub(path,i,j-i+1),crlf)
  255. i=j+1
  256. goto Looppath
  257.  
  258. :OKPATH
  259. display(6,"%a%, your DOS PATH is",strcat(pathwork,strsub(path,i,pathlen-i+1)))
  260.  
  261. dirchange(savecwd)
  262.  
  263. display(%TimeLong%,DaTitle,`Let's look at the clipboard and put some data in it`)
  264. ;  clipboard and random number stuff
  265. run("clipbrd.exe","")
  266. clipput(strcat("Clipboard Testing",crlf))
  267. b=clipget()
  268. clipput(strcat(b,"Random Numbers",crlf))
  269. b=random(100)
  270. clipappend(strcat(b,crlf))
  271. b=random(100)
  272. clipappend(strcat(b,crlf))
  273. b=random(100)
  274. clipappend(strcat(b,crlf))
  275.  
  276. display(3,DaTitle,"This is just a small sample of the power of BatchWorks")
  277.  
  278. display(3,DaTitle,"Now let's send some keystrokes to other applications...")
  279.  
  280. WinClose("Clipboard")
  281.  
  282. runzoom("write.exe","")
  283. sendkey("Greetings:~~")
  284. sendkey("This is an example of the {F6}PubTech BatchWorks{F6} SENDKEY function{sp}")
  285. sendkey("typing ordinary text into a Microsoft Write file.  You will notice that{sp}")
  286. sendkey("the process is reasonably quick.  Higher speeds may be obtained by using{sp}")
  287. sendkey("the clipboard functions, as used in the example below.{sp 2}")
  288. sendkey("The SENDKEY function can be used with the {F6}PubTech Macro{f6} facility{sp}")
  289. sendkey("to insert boilerplate text into documents.  For Example:~~")
  290.  
  291. sendkey("!CE{F6}")
  292. clipput("Copyright Notice")
  293. sendkey("+{insert}{F6}!CR!PC~~!PL")
  294. clipput('This manual is copyrighted.  All rights are reserved.  This document may ')
  295. clipappend('not, in whole or part, be copied, photocopied, reproduced, translated, or ')
  296. clipappend('reduced to any electronic medium or machine readable form without prior ')
  297. clipappend('consent, in writing, from ')
  298. sendkey("+{INSERT}{sp}{F6}")
  299. clipput("International Widgets.")
  300. sendkey("+{insert}{F6}~~")
  301. sendkey("This is the end of the SendKey/Write demo.")
  302. pause(DaTitle,"Hit OK to Continue")
  303. WinActivate("Write")
  304. sendkey("!FXN")
  305.  
  306.  
  307. ; Do a dialog box demo
  308. ; Menu choices range from a-z, and A-Z.  Menu actions are defined here.
  309. ; The correspondence is established by concatenating an "x" to the 
  310. ; menu choice variable name.
  311.  
  312. display(%TimeLong%,DaTitle,`You can create your own dialog boxes for Windows or non-windows apps`)
  313. display(%TimeLong%,DaTitle,`For instance, if you want to run any of the following apps...`)
  314. display(%TimeLong%,DaTitle,`Just select one from the menu and click OK...`)
  315.  
  316. Ax='Run("Notepad.exe","")'
  317. Bx='Run("Notepad.exe","Win.Ini")'
  318. Cx='Run("Control.exe","")'
  319. Dx='Run("Calendar.exe","")'
  320. Ex='Run("Cardfile.exe","")'
  321. Fx='Run("Write.exe","")'
  322.  
  323. :DBegin
  324. drop (A,B,C,D,E,F)
  325. drop (a,b,c,d,e,f)
  326. dialogbox("Menu","menu.dlg")
  327. LoopCntl=char2num("A")-1
  328. LoopLimit=char2num("F")
  329. :DLoop
  330. LoopCntl=LoopCntl+1
  331. If LoopCntl>LoopLimit then goto NextLoop
  332. testmenu=num2char(LoopCntl)
  333. testaction=strcat(testmenu,"x")
  334. If (IsDefined(%testmenu%)+IsDefined(%testaction%))!=(@true+@true) then goto DLoop
  335. action=%testaction%
  336. If %testmenu% then %action%
  337. goto DLoop
  338. :NextLoop
  339. if LoopLimit==char2num("f") then goto mdone
  340. LoopCntl=char2num("a")-1
  341. LoopLimit=char2num("f")
  342. goto DLoop
  343.  
  344. :mdone
  345. display(%TimeLong%,DaTitle,`You can also include radio buttons, list boxes and other items in dialog boxes`)
  346.  
  347. wincloseall("Desktop","CBM Desktop","PubTech File","File","MS-","Program")
  348.  
  349. display(%TimeLong%,DaTitle,`There are many other functions available...`)
  350. display(%TimeLong%,DaTitle,`You can create editable script files with PubTech Macro that can be run as Batches`) 
  351. display(%TimeLong%,DaTitle,`Macros can also be added to the System menu of any application`)
  352. display(%TimeLong%,DaTitle,`And you can compile batch files with the BatchWorks SDK available separately`)
  353. display(%TimeLong%,DaTitle,`This concludes the BatchWorks Demo`)
  354. display(10,DaTitle,`Call 1-800 PUBTECH or (512) 346-2835 for more information`)
  355.  
  356. ;   give the user a chance to cancel the demo
  357. askq=ASKYESNO("BatchWorks Demo","Do you want to restart the demo?")
  358. IF askq == @TRUE THEN GOTO START
  359.  
  360. display(%TimeShort%,DaTitle,`THANKS!`)
  361. GOTO end
  362.  
  363. :failure
  364. Message(DaTitle,"Item %y% failed")
  365. exit
  366. z = "failure"
  367.  
  368. :end
  369. exit
  370.